<template>
  <div class="searchPane">
    <Tree :data="layerType" @on-check-change="selectNode" show-checkbox  ref="layerTypeTree" ></Tree>
  </div>
</template>
<script>
  import LayerManager from './LayerManager'
  export default {
    name: 'Search',
    data () {
      return {
        layerType: [
          {
            title: 'parent 1',
            children: [
              {
                title: 'parent 1-1',
                children: [
                  {
                    title: 'leaf 1-1-1'
                  },
                  {
                    title: 'leaf 1-1-2'
                  }
                ]
              },
              {
                title: 'parent 1-2',
                children: [
                  {
                    title: 'leaf 1-2-1'
                  },
                  {
                    title: 'leaf 1-2-1'
                  }
                ]
              }
            ]
          }
        ]
      }
    },
    created:function () {
      var self = this;
      this.$http.get("./static/Data/tree_data3.json",
        {},
        {
          emulateJSON: true
        }).then(function (response) {
        var strLayer = JSON.stringify(response.body)
        self.layerType = JSON.parse(strLayer.replace(/text/g,'title'));
      }, function (error) {
        self.$Message.error('加载地址！');
      });
    },
    methods:{
      selectNode:function(data) {
        debugger
        console.log(data);
        LayerManager.addLayer(data);
      }
    }
  }
</script>

<style>


</style>
